home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
rfd12.arc
/
RFD.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-06-09
|
7KB
|
191 lines
; ╔════════════════════════════════════════════════════════════════════════╗
; ║ Program : RFD.ASM ║
; ║ Programmer : J. Stephen Redmond ║
; ║ ║
; ║ Syntax : RFD [d:]path [/Y] ║
; ║ Description : RFD removes the files and usbdirectory specified by the ║
; ║ path argument on the command line. RFD has two modes of ║
; ║ operation: 1> default command line mode, 2> batch mode. ║
; ║ 1> Default - warning is issued and user must respond ║
; ║ to proceed. (see warning message). ║
; ║ 2> Batch - specify '/Y' argument on cmmand line. ║
; ║ No warning will be issued and program will ║
; ║ attempt to remove director. ║
; ║ Both modes of operation issue an ERRORLEVEL code upon ║
; ║ termination as follows: ║
; ║ 99 - Syntax error ║
; ║ 98 - Operator terminated ║
; ║ 16 - Attempted to delete current directory ║
; ║ 5 - Protected file in subdirectory ║
; ║ 3 - Path not found ║
; ║ 0 - Successful completion ║
; ╚════════════════════════════════════════════════════════════════════════╝
; ╔════════════════════════════════════════════════════════════════════════╗
; ║ Code marked [ADDED-JH] or [CHANGED-JH] has been altered from that pub- ║
; ║ lished in PC Magazine to add carry checking to properly handle errors ║
; ║ The original code seems to function properly, but may return an error ║
; ║ code on sucessful completion. -- Joe Harrington 11/26/87 ║
; ╚════════════════════════════════════════════════════════════════════════╝
; ╔════════════════════════════════════════════════════════════════════════╗
; ║ Code marked [ADDED-GM] or [CHANGED-GM] has been altered from that pub- ║
; ║ lished in PC Magazine to handle errors slightly different and add an ║
; ║ additional Error Message for Error # 16. -- Gary Meeker 11/30/87 ║
; ╚════════════════════════════════════════════════════════════════════════╝
Code segment para public 'code'
assume cs:code
org 0100h ; .COM FILE, EXE2BIN
Begin: jmp start ; terminate and stay resident
db '(C) 1987, Ziff-Davis. By J. Stephen Redmond'
Question db '** WARNING ** - All files will be deleted!',13,10
db 'Do you wish to proceed (Y/N) ? $'
Msg1 db 'Syntax: RFD [d:]pathname [/Y]',13,10,'$' ;erlvl 99
Msg2 db 'Program terminated by operator',13,10,'$' ;erlvl 98
Msg5 db 'Cannot remove current directory',13,10,'$' ;erlvl 16 [ADDED - GM]
Msg3 db 'Protected files in subdirectory',13,10,'$';erlvl 05
Msg4 db 'Specified path not found',13,10,'$' ;erlvl 03
Crlf db 13,10,'$'
Pathname db 64 dup (?)
Wildcards db '\*.*',0
Opmode_sw db 1
Start proc near
cld
mov si, 80h ;point to path name length
mov cl, byte ptr [si] ;number of bytes on com line
cmp cl, 4 ;need at least 4 char to omit
jae Fix_up ; root directory
mov al, 99 ; syntax error
jmp Rfd_Exit
Fix_up: sub cl, 1 ;do not include leading space
xor ch, ch ;zero high half
push cx ;save length of pathname
mov al, '/' ;search for switch indicator
mov di, 82h ;start search here
repne scasb ;scan the string
jcxz Prompt ;no switch, ask user if ok
Switch: and byte ptr [di], 5Fh ;capitalize switch
cmp byte ptr [di], 'Y' ;is it the Y switch
jnz Prompt ;yes, skip prompt
pop cx ;get length of pathname
sub cx, 2 ;adjust for switch length
push cx ;save adjusted length
mov Opmode_sw, 0 ;set to batch mode
jmp Set_Path
Prompt: lea dx, Question ;query user
mov ah, 9 ;service 9, print string
int 21h
mov ah, 1 ;service 1, wait for keypress
int 21h ; and display it
and al, 5Fh ;captialize the response
cmp al, 'Y' ;proceed confirmation?
jz Set_Path ;yes proceed
mov al, 98 ;exit code
jmp Rfd_Exit
Set_Path: pop cx ;get path length
push cx ;save it again
mov si, 82h ;start move here
lea di, Pathname ;address of storage
repnz movsb ;move the pathname
mov byte ptr [di], 0 ;make pathname ASCIIZ
lea dx, Dta ;new disk transfer address
mov ah, 1Ah ;service 1A - set dta
int 21h
pop bp ;get length pathname
push bp ;save it again
lea si, Wildcards ;source sting
lea di, pathname[bp] ;destination string+offset
mov cx, 5 ;byte count for move
repnz movsb ;move in wildcards
lea dx, Pathname ;address pathname and wildcards
xor cx, cx ;zero attribute
mov ah, 4Eh ;Function 4E-Find first file
int 21h
jnc Delete ;[ADDED - JH]
cmp al, 18 ;files not found [CHANGED-JH]
je remove
jmp Rfd_Exit ;[ADDED - JH]
Delete: lea si, dta[30] ;where filename is stored
mov cx, 0Dh ;max 11 characters
lea di, Pathname[bp+1] ;after the '\'
repnz movsb ;store the filename in the
lea dx, Pathname ; full pathname
mov ah, 41h ;Function 41 - unlink
int 21h
jnc Deletenxt ;[ADDED - JH]
cmp al, 5 ;al=5 means protected file
je Rfd_Exit
Deletenxt: mov ah, 4Fh ;Function 4F-Find next
int 21h ; matching fIle
jnc Delete ;[ADDED - JH]
cmp al, 18 ;no more files found
jne Rfd_Exit ;[CHANGED - GM]
Remove: pop si ;length of pathname
mov Pathname[si], 0 ;make it ASCIIZ again
lea dx, Pathname
mov ah, 3Ah ;Function 3A-Remdir
int 21h
jc Rfd_Exit ;[ADDED - JH]
xor ax, ax ;[ADDED - JH]
Rfd_Exit: cmp Opmode_Sw, 0 ;0-Batch mode 1-Command
jz Batch_mode
push ax ;save errorcode
lea dx, Crlf ;next line on display
mov ah, 9 ;service 9-print string
int 21h
pop ax ;restore errorcode
cmp al, 99 ;99-Incorrect syntax
jnz E98
lea dx, Msg1
jmp Print
E98: cmp al, 98 ;98-User terminated
jnz E16 ;[CHANGED - GM]
lea dx, Msg2
jmp Print
E16: cmp al, 16 ;16-Cannot Delete Current Dir [ADDED - GM]
jnz E5 ;[ADDED - GM]
lea dx, Msg5 ;[ADDED - GM]
jmp Print ;[ADDED - GM]
E5: cmp al, 5 ;5-Protected file
jnz E3
lea dx, Msg3
jmp Print
E3: cmp al, 3 ;3-Path not found
jnz Batch_mode
lea dx, Msg4
Print: push ax ;save errorcode
mov ah, 9 ;service 9-print string
int 21h
pop ax
Batch_mode: mov ah, 4Ch ;service 4C-exit with code
int 21h
Start endp
Dta label byte ;to store disk data
code ends
end Begin